//
//  CustomHUDView.m
//  GANGAIKit
//
//  Created by fh on 2019/11/6.
//  Copyright © 2019 cashchina. All rights reserved.
//

#import "CustomHUDView.h"

@implementation CustomHUDView

#pragma mark - Life
- (instancetype)init {
    if (self = [super init]) {
        [self addSubview:self.uploadSpeedLabel];
        [self addSubview:self.uploadTimeLabel];
        [self addSubview:self.uploadProgressView];

        [self.uploadTimeLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
            make.right.top.equalTo(@(0));
            make.width.equalTo(self.uploadSpeedLabel.mas_width);
        }];
        [self.uploadSpeedLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
            make.top.left.equalTo(@(0));
            make.width.equalTo(self.uploadTimeLabel.mas_width);
        }];
        [self.uploadProgressView mas_remakeConstraints:^(MASConstraintMaker *make) {
            make.left.right.equalTo(@(0));
            make.height.equalTo(@(1.5));
            make.bottom.equalTo(self.mas_bottom).offset(-8);
        }];
    }
    return self;
}
/// 见文件MBProgressHUD.h的属性customView解释->285行
- (CGSize)intrinsicContentSize {
    return CGSizeMake([UIScreen mainScreen].bounds.size.width-50, 30.f);
}

#pragma mark - Setter and getter
- (UIProgressView *)uploadProgressView {
    if (!_uploadProgressView) {
        _uploadProgressView = [[UIProgressView alloc] init];
        _uploadProgressView.progressTintColor = [UIColor orangeColor];
    }
    return _uploadProgressView;
}
- (UILabel *)uploadTimeLabel {
    if (!_uploadTimeLabel) {
        _uploadTimeLabel = [UILabel new];
        _uploadTimeLabel.textColor = [UIColor whiteColor];
        _uploadTimeLabel.font = [UIFont systemFontOfSize:14];
        _uploadTimeLabel.textAlignment = NSTextAlignmentRight;
        _uploadTimeLabel.numberOfLines = 0;
        _uploadTimeLabel.text = @"00:00:00";
    }
    return _uploadTimeLabel;
}
- (UILabel *)uploadSpeedLabel {
    if (!_uploadSpeedLabel) {
        _uploadSpeedLabel = [UILabel new];
        _uploadSpeedLabel.textColor = [UIColor whiteColor];
        _uploadSpeedLabel.font = [UIFont systemFontOfSize:14];
        _uploadSpeedLabel.textAlignment = NSTextAlignmentLeft;
        _uploadSpeedLabel.numberOfLines = 0;
        _uploadSpeedLabel.text = @"0KB/s";
    }
    return _uploadSpeedLabel;
}
- (UILabel *)uploadStatusLabel {
    if (!_uploadStatusLabel) {
        _uploadStatusLabel = [UILabel new];
        _uploadStatusLabel.textColor = [UIColor whiteColor];
        _uploadStatusLabel.font = [UIFont systemFontOfSize:14];
        _uploadStatusLabel.textAlignment = NSTextAlignmentCenter;
        _uploadStatusLabel.numberOfLines = 0;
        _uploadStatusLabel.text = @"剩余时间:00:00:00\n上传速度:0KB/s";
    }
    return _uploadStatusLabel;
}

@end
